﻿// <copyright file="ChartControl.cs" company="Golizza.net">Copyright (c) 2012 All Right Reserved</copyright>

namespace Sharemarker.BinaryOptionApplication.Controls
{
    using System.Collections.ObjectModel;
    using System.Windows;
    using System.Windows.Controls;

    using Sharemarker.BinaryOptionApplication.Models;

    /// <summary>
    /// The control use to present the chart.
    /// </summary>
    public class ChartControl : Control
    {
        #region Static Fields

        /// <summary>
        /// Identifies the <see cref="Candles"/> dependency property.
        /// </summary>
        public static readonly DependencyProperty CandlesProperty = DependencyProperty.Register(
            "Candles", typeof(ObservableCollection<Tick>), typeof(ChartControl));

        /// <summary>
        /// Identifies the <see cref="CurrencyPair"/> dependency property.
        /// </summary>
        public static readonly DependencyProperty CurrencyPairProperty = DependencyProperty.Register(
            "CurrencyPair", typeof(CurrencyPair), typeof(ChartControl));

        /// <summary>
        /// Identifies the <see cref="TimeFrame"/> dependency property.
        /// </summary>
        public static readonly DependencyProperty TimeFrameProperty = DependencyProperty.Register(
            "TimeFrame", typeof(TimeFrame), typeof(ChartControl));

        #endregion

        #region Constructors and Destructors

        /// <summary>
        /// Initializes static members of the <see cref="ChartControl" /> class.
        /// </summary>
        static ChartControl()
        {
            DefaultStyleKeyProperty.OverrideMetadata(
                typeof(ChartControl), new FrameworkPropertyMetadata(typeof(ChartControl)));
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ChartControl" /> class.
        /// </summary>
        public ChartControl()
        {
            this.SetValue(CandlesProperty, new ObservableCollection<Tick>());
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets the candle collection.
        /// </summary>
        public ObservableCollection<Tick> Candles
        {
            get
            {
                return this.GetValue(CandlesProperty) as ObservableCollection<Tick>;
            }
        }

        /// <summary>
        /// Gets or sets the Currency pair
        /// </summary>
        public CurrencyPair CurrencyPair
        {
            get
            {
                return this.GetValue(CurrencyPairProperty) as CurrencyPair;
            }

            set
            {
                this.SetValue(CurrencyPairProperty, value);
            }
        }

        /// <summary>
        /// Gets or sets the time frame.
        /// </summary>
        public TimeFrame TimeFrame
        {
            get
            {
                return this.GetValue(TimeFrameProperty) as TimeFrame;
            }

            set
            {
                this.SetValue(TimeFrameProperty, value);
            }
        }

        #endregion
    }
}